package com.example.combwx.mvp.model.entity;

import com.example.combwx.mvp.base.model.BaseEntity;
import com.google.gson.Gson;


import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

public class TextBannerEntity extends BaseEntity {
    public String values;
    public List<Values> getValues(){
        if (values.isEmpty())
            return null;
            List<Values> list = new ArrayList<>();
            JSONArray jsonArray = null;
            try {
                jsonArray = new JSONArray(values);
                for (int i = 0; i < jsonArray.length(); i++) {
                    String item = jsonArray.getString(i);
                    Values entity = new Gson().fromJson(item, Values.class);
                    list.add(entity);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < 5; i++) {
                Values entity = list.get(0);
                list.add(entity);
            }
            return list;
    }

    public static class Values{
        public int news_type;
        public String news_author;
        public String news_value;
        public String news_title;
        public String news_url;
        public long news_time;
        public long author_id;
        public long channel_id;
        public long news_id;
    }
}
